classdef GetSample 
    %This is a class for retrieving data
    properties
       SampleStart;
       SampleEnd;
       StartIndex;
       EndIndex;
       filename;
       dataOut;
       retData;
       sizeData;
       dates;
    end
    
    methods
    
        function [ eret, T ] = getExcessReturnsFromFile(obj)
                filedata  = obj.dataOut;
                StartLoc = find(filedata(:,1)==obj.SampleStart);
                EndLoc = find(filedata(:,1)==obj.SampleEnd);
                ret=filedata(StartLoc:EndLoc,2:end)'/100;
                obj.dates = obj.dates(StartLoc:EndLoc,1);
                rf = obj.getRf();
                ret((ret<-0.98))=NaN;
                eret=ret-ones(size(ret,1),1)*rf';
                T=size(eret,2);

        end

            function rf = getRf(obj)
                    load('FF_Rf.txt') 
                    StartLoc = find(FF_Rf(:,1)==obj.SampleStart);
                    EndLoc = find(FF_Rf(:,1)==obj.SampleEnd);
                    rf=FF_Rf(StartLoc:EndLoc,5)/100;
            end
   end
    
end

